function initDataShop() {
    var map = new Map();
    for (let i = 0; i < localStorage.length; i++) {
        map.set(localStorage.key(i), JSON.parse(localStorage.getItem(localStorage.key(i))));
    };

    var str = '';
    map.forEach(function(ele, i) {
        str += `
                <li class="cart_item last">
                <div class="cart_item_pic">
                    <a href="">
                        <img src="${ele.uimg}" alt="">
                    </a>
                </div>
                <div class="cart_item_desc">
                    <a href="" class="cart_item_name">${ele.utitle}</a>
                    <div class="lie">
                        <div class="cart_item_price">
                            <div class="cart_price">￥${ele.uprice}</div>
                            <div class="delete_cart">
                                <a href="javascript:void(0)" data-id="${ele.uid}">删除</a>
                            </div>
                        </div>
                    </div>
                    <div class="p-number">
                        <a href="javascript:void(0)" class="count-remove">-</a>
                        <span class="num">${ele.num}</span>
                        <a href="javascript:void(0)" class="count-add">+</a>
                    </div>
                </div>
                </li>`;
        $('.ibar_cart_product>ul').html(str);
    });

    if ($('.cart_item').length > 0) {
        $('.ecs-tbar-tipbox2').css('display', 'none');
        $('.ibar_cart_group').css('display', 'block');
    } else {
        $('.ecs-tbar-tipbox2').css('display', 'block');
        $('.ibar_cart_group').css('display', 'none');
    };

    $('.cart_handler_right').text('￥' + Number($('.cart_price').text()) * Number($('.num').text()));
    $('.count-remove').click(function() {
        var count = Number($(this).next().text());
        if (count > 1) {
            count--;
            $(this).next().text(count);
        } else {
            count = 1;
            $(this).next().text(count);
        }
        add();
    });

    $('.count-add').click(function() {
        var count = Number($(this).prev().text());
        count++;
        $(this).prev().text(count);
        add();
    });

    function add() {
        var num = 0;
        $('.num').each(function(i, e) {
            num += Number($(e).text());
        });
        $('.cart_num').text(num);
        sumPrice();
    };
    add();

    function sumPrice() {
        var sumprice = 0;
        $('.num').each(function(i, e) {
            sumprice += Number($(this).text()) * Number($(this).parent().prev().find('.cart_price').text());
        });
        $('.cart_handler_right').text('￥' + sumprice);
    };

    function delBtn() {
        $('.delete_cart>a').click(function() {
            var delId = $(this).attr('data-id');
            if (confirm('你真的要删除这件商品吗')) {
                localStorage.removeItem(delId);
                initDataShop();
            };
        });

    };
    delBtn();
};
initDataShop();